Skip to content

GH-4437: Sign and normalise fn:*-from-duration results - #4441

Open
Kulraj69 wants to merge 1 commit into
apache:mainfrom
Kulraj69:GH-4437-duration-components
Open

Kulraj69 wants to merge 1 commit into
apache:mainfrom
Kulraj69:GH-4437-duration-components

Conversation

@Kulraj69

Copy link
Copy Markdown

GitHub issue resolved #4437

Pull request Description:

fn:years-from-duration and the other five *-from-duration functions returned the field as written in the lexical form, so the sign was dropped and fields weren't normalised (-P3DT10H gave 3 days, PT123H gave 123 hours).

XSDFuncOp.accessDuration now works out the components from the canonical form: years/months from total months, days/hours/minutes/seconds from the day-time part, then applies the duration's sign. The two halves are normalised separately, so a plain xs:duration still gets years and months from the year-month part only.

YEAR(), MONTH() etc. on a duration go through the same code, so they change the same way.

Tests: added the F&O 3.1 §8.2 examples from the issue (negative and overflowing values, plus a dateTime subtraction) to TestFnFunctionsDateTimeDuration. They fail on main and pass with the fix. Full jena-arq test run passes locally on Java 21.

I used an AI assistant (Devin) while working on this and reviewed the change; the commit has a Generated-by: trailer per the ASF guidance.


  • Tests are included.
  • Documentation change and updates are provided for the Apache Jena website
  • Commits have been squashed to remove intermediate development commit messages.
  • Key commit messages start with the issue number (GH-xxxx)

By submitting this pull request, I acknowledge that I am making a contribution to the Apache Software Foundation under the terms and conditions of the Contributor's Agreement.


See the Apache Jena "Contributing" guide.

Read the components from the canonical form of the duration and apply
its sign, as F&O 3.1 section 8.2 defines them.

Generated-by: Devin (AI-assisted)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fn:*-from-duration functions drop the sign and do not normalise the duration

1 participant